//
//  StudioCollectionViewCell.m
//  Arts1
//
//  Created by 孤星晨宇 on 15/9/21.
//  Copyright (c) 2015年 Arts1. All rights reserved.
//

#import "StudioCollectionViewCell.h"
#import "AllHeader.h"
#import <UIImageView+WebCache.h>


@implementation StudioCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.backgroundColor = [UIColor clearColor];
        
        UIView *whiteView = [[UIView alloc] initWithFrame:CGRectMake( 0, 0, SCREEN_WIDTH - 20, 70)];
        whiteView.backgroundColor = [UIColor whiteColor];
        whiteView.layer.cornerRadius = 4;
        [UIView viewShadowColor:whiteView];
        
        _imageViem = [[UIImageView alloc] initWithFrame:CGRectMake(5, 5, 60, 60)];
        _imageViem.image = [UIImage imageNamed:@"7.jpeg"];
        [_imageViem setContentMode:(UIViewContentModeScaleAspectFill)];
        _imageViem.layer.cornerRadius = 2;
        _imageViem.backgroundColor = kRandomColor;
        _imageViem.layer.masksToBounds = YES;
        _imageViem.userInteractionEnabled = YES;
        [whiteView addSubview:_imageViem];
        
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(_imageViem.width + 13, 5, whiteView.width - _imageViem.width - 20, 16)];
//        _titleLabel.text = @"titleLabel";
        _titleLabel.textColor = kCustomColor(150, 150, 150, 1);
        _titleLabel.font = [UIFont fontWithName:@"PingFangSC-Semibold" size:13];
        [whiteView addSubview:_titleLabel];
        
        _subtitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(_imageViem.width + 13, _titleLabel.bottom, whiteView.width - _imageViem.width - 20, 20)];
//        _subtitleLabel.text = @"titleLabel";
        _subtitleLabel.textColor = kCustomColor(40, 40, 50, 1);
        _subtitleLabel.font = [UIFont fontWithName:@"PingFangSC-Semibold" size:11];
        [whiteView addSubview:_subtitleLabel];
        
        //        _iconImageView = [[UIImageView alloc] initWithFrame:CGRectMake(_imageViem.right + 10, _subtitleLabel.bottom + 2, 24, 24)];
        //        _iconImageView.image = [UIImage imageNamed:@"4.jpeg"];
        //        _iconImageView.layer.cornerRadius = 14;
        //        _iconImageView.layer.masksToBounds = YES;
        //        [whiteView addSubview:_iconImageView];
        
        _attention = [[UILabel alloc] initWithFrame:CGRectMake(_imageViem.width + 13, _imageViem.bottom - 20, 65, 20)];
        _attention.font = [UIFont fontWithName:@"PingFangSC-Semibold" size:11];
//        _attention.text = @"关注 1860";
        _attention.textColor = kCustomColor(150, 150, 150, 1);
        [whiteView addSubview:_attention];
        
        _commentLabel = [[UILabel alloc] initWithFrame:CGRectMake(_attention.right + 3, _attention.top, 65, 20)];
        _commentLabel.font = [UIFont fontWithName:@"PingFangSC-Semibold" size:11];
        _commentLabel.text = @"报名 1860";
        _commentLabel.textColor = kCustomColor(150, 150, 150, 1);
        [whiteView addSubview:_commentLabel];
        
//        _registrator = [[UILabel alloc] initWithFrame:CGRectMake(_commentLabel.right + 3, _imageViem.bottom - 20, 65, 20)];
//        _registrator.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:13];
//        _registrator.text = @"评论 1860";
//        _registrator.textColor = [UIColor colorWithRed: 0.3922 green: 0.3922 blue: 0.3922 alpha: 1.0];
//        [whiteView addSubview:_registrator];
        
        [self.contentView addSubview:whiteView];
        
//        // 展示阴影感觉的效果
//        _grandlayout = [CAGradientLayer layer];
//        _grandlayout.frame = CGRectMake(0, 0, whiteView.bounds.size.width,whiteView.bounds.size.height);
//        //        _grandlayout.colors = @[(id)[UIColor colorWithHue:0.8 saturation:0.8 brightness:0.8 alpha:0],(id)[UIColor colorWithHue:1.0 saturation:1.0 brightness:1.0 alpha:1.0]];
//        
//        _grandlayout.colors = @[(id)kCustomColor(244, 244, 244, 0).CGColor, (id)kCustomColor(255, 255, 255, 0).CGColor];
//        _grandlayout.startPoint = CGPointMake(0, 0);
//        _grandlayout.endPoint = CGPointMake(0, 1);
//        [whiteView.layer addSublayer:_grandlayout];
        
        //  [UIColor colorWithRed:0 green:0.3 blue:0 alpha:1]
        
    }
    return self;
}

- (void)setStudio:(SpaceModel *)studio{
    _studio = studio;
    [_imageViem sd_setImageWithURL:[NSURL URLWithString:_studio.headImg]];
    _titleLabel.text = _studio.spaceName;
    _subtitleLabel.text = _studio.type;
    _attention.text = [NSString stringWithFormat:@"关注 %@",_studio.follows];
    _commentLabel.text = [NSString stringWithFormat:@"报名"];
    
}

- (void)setModel:(AttentionStudioModel *)model
{
    _model = model;
    [_imageViem sd_setImageWithURL:[NSURL URLWithString:_model.headImg] placeholderImage:nil options:SDWebImageRetryFailed | SDWebImageLowPriority];
    _titleLabel.text = _model.spaceName;
    _attention.text = [NSString stringWithFormat:@"关注 %@",_model.follows];
    _commentLabel.text = [NSString stringWithFormat:@"报名 %@",_model.bookNum];
//    _attention.text = _model.
}

@end
